#include "XThread.h"
#include <process.h>
#include <windows.h>
static void ThreadMain(void *para)
{
	XThread *th = (XThread *)para;
	th->Main();
	_endthread();
}
bool XThread::Start()
{
	th = _beginthread(ThreadMain, 0, this);
	if ((int)th <= 0)
	{
		return false;
	}
	return true;
}
XThread::XThread()
{
}


XThread::~XThread()
{
}

void XThread::Wait()
{
	if (th == 0)return;
	WaitForSingleObject((HANDLE)th, INFINITE);
}

void XThread::Suspend()
{
	if (th == 0)return;
	SuspendThread((HANDLE)th);
}
void XThread::Resume()
{
	if (th == 0) return;
	ResumeThread((HANDLE)th);
}
